<%-- 
    Document   : addManufacturer
    Created on : Nov 3, 2011, 2:00:01 AM
    Author     : Admin
--%>

<%@page import="javax.rmi.PortableRemoteObject"%>
<%@page import="manufacturerBean.ManufacturerHome"%>
<%@page import="manufacturerBean.Manufacturer"%>
<%@page import="categorybean.Category"%>
<%@page import="categorybean.CategoryHome"%>
<%@page import="GoodsBean.Goods"%>
<%@page import="GoodsBean.GoodsHome"%>
<%@page import="javax.naming.InitialContext"%>
<%@page import="DBConnection.ATeamObject"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Добавление производителя</title>
        <%  InitialContext initialContext;
            GoodsHome goodsHome;
            Goods goods;
            Object homeObject;

            CategoryHome categoryHome;
            Category category;
            Object homeObject1;

            Manufacturer manufacturer;
            ManufacturerHome manufacturerHome;
            Object homeObject2;

            ATeamObject ato = new ATeamObject();

            try {
                initialContext = new InitialContext();
                homeObject = initialContext.lookup("GoodsBean");
                goodsHome = (GoodsHome) PortableRemoteObject.narrow(homeObject,
                        GoodsHome.class);

                homeObject1 = initialContext.lookup("CategoryBean");
                categoryHome = (CategoryHome) PortableRemoteObject.narrow(homeObject1,
                        CategoryHome.class);

                homeObject2 = initialContext.lookup("ManufacturerBean");
                manufacturerHome = (ManufacturerHome) PortableRemoteObject.narrow(homeObject2,
                        ManufacturerHome.class);
        %>
    </head>
    <body background="1.jpg" bgproperties="fixed">
        <h4><a href="index.jsp">Главная</a>></h4>
        <a href="addManufacturer.jsp">Добавление производителя</a>
        <h1>Добавление производителя</h1>
        <%  if (request.getParameter("name") != null) {                
                ato.setName(request.getParameter("name"));
                ato.setObjectDescription(request.getParameter("description"));
                manufacturer = manufacturerHome.create(ato);                
                response.sendRedirect("index.jsp");
            }
            
        %>
        <form action="addManufacturer.jsp" method="POST">
            <p>Введите название производителя</p>
            <input type="text" name="name" value="" size="50" />
            <p>Введите описание производителя</p>
            <input type="text" name="description" value="" size="50" />
            <p><input type="submit" value="Добавить" name="add" /></p>
        </form>
        <% } catch (Exception e) {
                e.printStackTrace(System.err);
            }
        %>
    </body>
</html>
